package com.xxc.modules.home.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.xxc.modules.home.entity.OrderEntity;
import com.xxc.modules.home.service.OrderService;
import com.xxc.modules.home.service.ProjectService;
import com.xxc.modules.member.service.MemberService;
import com.xxc.common.utils.Query;
import com.xxc.common.utils.R;

/**
 * 预约管理
 */
@RestController
@RequestMapping("order")
public class OrderController {
    @Autowired
    private OrderService orderService;
    @Autowired
    private MemberService memberService;
    @Autowired
    private ProjectService projectService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params) {
        //查询列表数据
        Query query = new Query(params);
        List<OrderEntity> orderList = orderService.queryList(query);
        int total = orderService.queryTotal(query);
        return R.ok().put("rows", orderList).put("total", total);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id) {
        OrderEntity order = orderService.queryObject(id);
        return R.ok().put("order", order);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody OrderEntity order) {
        orderService.save(order);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody OrderEntity order) {
        orderService.update(order);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids) {
        orderService.deleteBatch(ids);
        return R.ok();
    }

    /**
     * 完成
     */
    @RequestMapping("/complete")
    public R complete(@RequestBody Integer[] ids) {
        orderService.complete(ids);
        return R.ok();
    }
}
